#include <avz.h>
#include "helium/helium_helper_se.h"
#include "SimpleAvZ/lib.h"

using namespace AvZ;

void Script()
{
    SeedSlot(10);                                    // 10 卡槽
    OpenMultipleEffective('Q', MAIN_UI_OR_FIGHT_UI); // 反复重开
    SetAdvancedPauseKey('Z');                        // 高级暂停
    SetSkipTickKey('S', 9);                          // 跳帧
    SetSkipTickKey('D', 19);
    // SetErrorMode(CONSOLE);

    // 测试用
    // SetZombies({HY_32});
    // SetRowProperty(1, 0, 0, 0, 0, 0);
    // SetWavelength({{1, 746}, {2, 746}, {3, 1243}, {4, 1486}, {5, 746}, {6, 1243}, {7, 1813}, {8, 746}, {10, 680}, {11, 746}, {12, 1243}, {13, 1486}, {14, 746}, {15, 1243}, {16, 1486}, {17, 746}, {18, 1813}});

    SetZombies_AllType(PE);
    SelectCards({
        ICE_SHROOM,     // I
        M_ICE_SHROOM,   // I'
        DOOM_SHROOM,    // N
        COFFEE_BEAN,    // 咖啡豆
        CHERRY_BOMB,    // A
        LILY_PAD,       // 睡莲
        PUFF_SHROOM,    // c
        SUN_SHROOM,     // c
        SCAREDY_SHROOM, // c
        FLOWER_POT,     // c
    });

    SetTime(-599, 1);
    AvZ::MaidCheats::dancing();

    SetIce({{1, 6}, {2, 6}});

    for (auto wave : waves(1, 2, 5, 8, 11, 14, 18))
    {
        // PPDD 746
        PP(546, 8.3875);
        DD(after(107), 7.4125);

        if (wave == 2 || wave == 5 || wave == 11 || wave == 14)
        {
            I(746 + 5);
        }
    }

    for (auto wave : waves(10))
    {
        // PPNdd
        PP(480, 8.4375);
        C(480, keep(300), {LILY, DOOM, COFFEE}, 4, 8);
        DD(after(254), {2, 5}, 4); // 不晚于737
    }

    for (auto wave : waves(3, 6, 12, 15))
    {
        // I-PPdd 1243
        PP(1043);
        DD(after(356), 2.5);

        I(1243 + 11);
    }

    for (auto wave : waves(4, 13, 16))
    {
        // I-PPdd 1486
        PP(1286, 8.4875);
        DD(after(350), 2.5);

        if (wave == 16)
        {
            I(1486 + 11);
        }
    }

    for (auto wave : waves(7, 17))
    {
        // I-A-PPdd
        C(1383, keep(101), {LILY, CHERRY}, 3, 7); // 不伤本波红最晚1116，漏海豚
        C(after(-851), until(1714), LILY, 3, 8);
        PP(1609, {1, 5}, 8.4); // 延迟230/226
        DD(after(346), 2.5);
    }

    for (auto wave : waves(9))
    {
        // Ndd-BI-PD/DD
        C(464, keep(300), {LILY, DOOM, COFFEE}, 3, 9);
        DD(after(256), 2.5);

        B(1300, 5, 1.5);
        I(546 + 751);

        P(2529 - 220, 2, 8);
        D(2529, 1, 7);
        P(2529 + 126, 5, 8);
        D(after(220), 5, 6.5);

        PP(4300, 8);
    }

    for (auto wave : waves(19))
    {
        // Ndd-BI-PD/DD
        SetIce(1000, {{1, 2}}); // 停止存冰

        C(464, keep(300), {LILY, DOOM, COFFEE}, 4, 9);
        DD(after(256), 2.5);

        B(1300, 1, 1.5);
        I(546 + 751);

        P(2529 - 220, 2, 8);
        D(2529, 1, 7);
        P(2529 + 126, 5, 8);
        D(after(220), 5, 6.5);

        PP(4300, 8);
        C(1300, M_ICE_SHROOM, 1, 1);
    }

    for (auto wave : waves(20))
    {
        P(249, 4, 7.5875);
        P(394, 3, 3.5);
        C(200, COFFEE, 1, 1);
        PP(1317, 8.4875);
        PP(now);
        DD(after(220), 8.3625);

        PP(2000, 1);

        PP(3500, 8);
    }

    SetTime(0, 20);
    AvZ::MaidCheats::move();
    SetTime(3000, 20);
    AvZ::MaidCheats::dancing();
}